// -------------------------------------------------
// BlinKit - BlinKit Library
// -------------------------------------------------
//   File Name: node_list.cpp
// Description: NodeList Class
//      Author: Ziming Li
//     Created: 2021-07-21
// -------------------------------------------------
// Copyright (C) 2021 MingYang Software Technology.
// -------------------------------------------------

// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "./node_list.h"

#include "blinkit/blink/renderer/bindings/core/script_controller.h"

namespace blink {

void NodeList::OnBind(JSContext *ctx, JSValue scriptObject)
{
    ScriptController *scriptController = ScriptController::From(ctx);

    const unsigned n = length();
    for (unsigned i = 0; i < n; ++i)
    {
        Node *node = item(i);
        JS_SetPropertyUint32(ctx, scriptObject, i, scriptController->WrapNode(node));
    }
}

} // namespace blink
